/*
 * Copyright (c) 2024 -present FengJinjian ( 751965763@qq.com )

 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package edu.vital.energy.longevity.vitalenergy.code.generator.code;

import com.baomidou.mybatisplus.generator.config.builder.CustomFile;
import java.util.List;
import java.util.stream.Stream;

/**
 * TemplateInfo - 模板信息配置类
 *
 * @version 1.0.1
 * @author FengJinJian
 * @date 2025/1/13 14:51
 */
public class TemplateInfo {
    String  outputDir = "C:\\Users\\Administrator\\IdeaProjects\\lab3\\vital-energy-code-generator\\src\\main";

    public record Template(String templatePath, String outputFileNamePattern, String category, String outputPath) {}

    private CustomFile buildCustomFile(Template template) {
        return new CustomFile.Builder()
            .templatePath(template.templatePath())
            .fileName(template.outputFileNamePattern())
            .packageName(template.category())
            .filePath(template.outputPath())
            .enableFileOverride()
            .build();
    }

    public List<CustomFile> getCustomFiles() {
        // 定义所有模板
        List<Template> templates = List.of(
            new Template("templates/vue/api.ts.ftl", ".ts", "api", outputDir+"/vue/api/")
//            new Template("templates/vue/components/list.vue.ftl", "%sList.vue", "components", "src/components/"),
//            new Template("templates/vue/components/form.vue.ftl", "%sForm.vue", "components", "src/components/"),
//            new Template("templates/vue/components/search.vue.ftl", "%sSearch.vue", "components", "src/components/"),
//            new Template("templates/vue/components/detail.vue.ftl", "%sDetail.vue", "components", "src/components/")
        );

        // 将模板转换为 CustomFile
        return templates.stream()
            .map(this::buildCustomFile)
            .toList();
    }
}
